/*
 * scim-dbus-frontend.h
 *
 *  Created on: 2008-7-6
 *      Author: zarra
 */

#ifndef SCIMDBUSFRONTEND_H_
#define SCIMDBUSFRONTEND_H_

#define Uses_SCIM_TRANSACTION
#define Uses_SCIM_LOOKUP_TABLE
#define Uses_SCIM_FRONTEND
#include <scim.h>
#include "scim-adaptor.h"
class ScimSide;
class DBusSide: public org::scim::frontend,
		public DBus::IntrospectableAdaptor,
		public DBus::ObjectAdaptor {
private:
	ScimSide* m_scim_side;
public:
	DBusSide( DBus::Connection& connection,ScimSide* scimside );
public:
	void get_factory_list_for_encoding(const ::DBus::String& encoding,
			std::vector< ::DBus::String>& uuids, ::DBus::UInt32& count);

	void get_factory_list_for_language(const ::DBus::String& language,
			std::vector< ::DBus::String>& uuids, ::DBus::UInt32& count);

	::DBus::String get_default_factory(const ::DBus::String& language,
			const ::DBus::String& encoding);

	void set_default_factory(const ::DBus::String& language,
			const ::DBus::String& uuid);

	::DBus::String get_next_factory(const ::DBus::String& language,
			const ::DBus::String& encoding, const ::DBus::String& cur_uuid);

	::DBus::String get_previous_factory(const ::DBus::String& language,
			const ::DBus::String& encoding, const ::DBus::String& cur_uuid);

	::DBus::String get_factory_name(const ::DBus::String& uuid);

	::DBus::String get_factory_authors(const ::DBus::String& uuid);

	::DBus::String get_factory_credits(const ::DBus::String& uuid);

	::DBus::String get_factory_help(const ::DBus::String& uuid);

	::DBus::String get_factory_icon_file(const ::DBus::String& uuid);

	::DBus::String get_factory_locales(const ::DBus::String& uuid);

	::DBus::String get_factory_language(const ::DBus::String& uuid);

	::DBus::Bool validate_factory(const ::DBus::String& uuid,
			const ::DBus::String& encoding);

	::DBus::String get_all_locales();

	::DBus::Int32 new_instance(const ::DBus::String& sf_uuid,
			const ::DBus::String& encoding);

	::DBus::Bool replace_instance(const ::DBus::Int32& si_id,
			const ::DBus::String& sf_uuid);

	::DBus::Bool delete_instance(const ::DBus::Int32& id);

	void delete_all_instances();

	::DBus::String get_instance_uuid(const ::DBus::Int32& id);

	::DBus::String get_instance_encoding(const ::DBus::Int32& id);

	::DBus::String get_instance_name(const ::DBus::Int32& id);

	::DBus::String get_instance_authors(const ::DBus::Int32& id);

	::DBus::String get_instance_credits(const ::DBus::Int32& id);

	::DBus::String get_instance_help(const ::DBus::Int32& id);

	::DBus::String get_instance_icon_file(const ::DBus::Int32& id);

	::DBus::Bool process_key_event(const ::DBus::Int32& id,
			const ::DBus::String& key);

	void move_preedit_caret(const ::DBus::Int32& id, const ::DBus::UInt32& pos);

	void select_candidate(const ::DBus::Int32& id, const ::DBus::UInt32& index);

	void update_lookup_table_page_size(const ::DBus::Int32& id,
			const ::DBus::UInt32& page_size);

	void lookup_table_page_up(const ::DBus::Int32& id);

	void lookup_table_page_down(const ::DBus::Int32& id);

	void reset(const ::DBus::Int32& id);

	void focus_in(const ::DBus::Int32& id);

	void focus_out(const ::DBus::Int32& id);

	void trigger_property(const ::DBus::Int32& id,
			const ::DBus::String& property);

	void update_client_capabilities(const ::DBus::Int32& id,
			const ::DBus::UInt32& cap);

};

class ScimSide: public scim::FrontEndBase {
private:
	DBusSide* m_dbus_side;
	int id;
public:
	ScimSide(const scim::BackEndPointer& backend);
	void init(int argc, char **argv);
	void run();
public:
	//signals
	virtual void show_preedit_string(int id);

	virtual void show_aux_string(int id);

	virtual void show_lookup_table(int id);

	virtual void hide_preedit_string(int id);

	virtual void hide_aux_string(int id);

	virtual void hide_lookup_table(int id);

	virtual void update_preedit_caret(int id, int caret);

	virtual void update_preedit_string(int id, const scim::WideString & str,
			const scim::AttributeList & attrs);

	virtual void update_aux_string(int id, const scim::WideString & str,
			const scim::AttributeList & attrs);

	virtual void update_lookup_table(int id, const scim::LookupTable & table);

	virtual void commit_string(int id, const scim::WideString & str);

	virtual void forward_key_event(int id, const scim::KeyEvent & key);

	virtual void register_properties(int id,
			const scim::PropertyList & properties);

	virtual void update_property(int id, const scim::Property & property);

	virtual void beep(int id);

	//	    virtual void start_helper          (int id, const String &helper_uuid);
	//
	//	    virtual void stop_helper           (int id, const String &helper_uuid);
	//
	//	    virtual void send_helper_event     (int id, const String &helper_uuid, const Transaction &trans);
	//
	//	    virtual bool get_surrounding_text  (int id, WideString &text, int &cursor, int maxlen_before, int maxlen_after);
	//
	//	    virtual bool delete_surrounding_text  (int id, int offset, int len);
	friend class DBusSide;
};
#endif /* SCIMDBUSFRONTEND_H_ */
